#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int a[MAXN];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", a + i);
  std::sort(a + 1, a + n + 1, greater<int>());
  // std::reverse(a + 1, a + n + 1);
  for (int x = 1; x <= n; ++x) {
    if (a[x] < x) {
      printf("%d\n", x - 1);
      return 0;
    }
  }
  printf("%d\n", n);
  return 0;
}